package com.verisette.ncos.service.master.bizunit;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;

import org.corp.agi.common.exception.ProcessException;
import org.corp.agi.service.bean.ProcessContext;
import org.corp.agi.service.bizunit.CommonBusinessUnit;
import com.verisette.ncos.persistence.dao.UserProfileManagementDAO;
import com.verisette.ncos.persistence.domain.CustomMasterUserProfile;
import com.verisette.ncos.persistence.domain.MasterUserProfile;

public class ViewUserProfileManagementBU extends CommonBusinessUnit {

	private Logger logger = Logger.getLogger(ViewUserProfileManagementBU.class);
	
	private UserProfileManagementDAO userProfileManagementDAO;
	@Required
	@Autowired
	public void setUserProfileManagementDAO(UserProfileManagementDAO userProfileManagementDAO) {
		this.userProfileManagementDAO = userProfileManagementDAO;
	} 
	
	@Override
	public void execute(ProcessContext processContext) throws ProcessException {
		if(logger.isInfoEnabled()) logger.info( this.getClass().getSimpleName() + ": execute" );
		
		MasterUserProfile userProfile = (MasterUserProfile)processContext.getValueObject();
		
		List<CustomMasterUserProfile> customMasterUserProfileList = null;
		
		// View UserProfile
		logger.debug("1.View UserProfile");
		logger.debug("--> username : " + userProfile);
		
		customMasterUserProfileList = userProfileManagementDAO.viewUserProfile(userProfile);
		
		logger.debug("Result : ");
		
		if(customMasterUserProfileList != null && customMasterUserProfileList.size()!= 0)
			logger.debug("--> Found record !!! : " + customMasterUserProfileList.size());
		else
			logger.debug("--> Not found record !!! : ");
		
		processContext.setValueObject(customMasterUserProfileList);
		
	}
	
}
